package com.xcc.cloud.gateway.config;


import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * gateway的代碼配置訪問
 */
@Configuration
public class GatewayConfig {

    @Bean
    public RouteLocator customRouteLocator(RouteLocatorBuilder routeLocatorBuilder) {
        RouteLocatorBuilder.Builder routes = routeLocatorBuilder.routes();
        //routeId:path_rote_guonei     http://localhost:9527/guonei ==> http://news.baidu.com/guoji
        routes.route("path_rote_guonei", r -> r.path("/guonei").uri("http://news.baidu.com/guoji"))
            .route("path_rote_guoji", r -> r.path("/guoji").uri("http://news.baidu.com/guoji")).build();
        return routes.build();
    }

}
